package cc.catface.api.business.admin;

import cc.catface.common.output.ResultBody;
import cc.catface.dao.admin.pojo.AdChannel;
import cc.catface.dao.admin.pojo.AdChannelAddInputDTO;
import cc.catface.service.admin.AdChannelServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/admin/v1/channel")
@Api(tags = "[管理]频道")
public class AdChannelController {
    @Autowired
    private AdChannelServiceImpl channelService;

    @ApiOperation("查询频道(根据name)")
    @GetMapping("get")
    public ResultBody get(String name) {
        return channelService.get(name);
    }

    @ApiOperation(value = "新增频道,同时关联标签表")
    @PostMapping("add")
    public ResultBody add(@RequestBody AdChannelAddInputDTO input) {
        return channelService.add(input);
    }

    /**
     * 可更新频道名、描述、可用状态等
     */
    @ApiOperation(value = "更新频道(根据id)")
    @PostMapping("update")
    public ResultBody update(@RequestBody AdChannel channel) {
        return channelService.update(channel);
    }

    @ApiOperation(value = "查询所有频道")
    @GetMapping("list")
    public ResultBody list() {
        return channelService.list();
    }

    @ApiOperation("查询所有标签和频道")
    @GetMapping("listDetail")
    public ResultBody listDetail() {
        return channelService.listDetail();
    }
}
